package com.wzxy.controller;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/file")
public class FileUpload {
	
	@RequestMapping(value = "/doUpload",method = RequestMethod.POST)
	public String doUploadFile(MultipartFile file) throws IOException{
		
		if(!file.isEmpty()){
			System.out.println("正在处理文件...");
			FileUtils.copyInputStreamToFile(file.getInputStream(), new File("D:\\file\\",System.currentTimeMillis()+file.getOriginalFilename()));
		}
		return "success";
	}
}
